package com.zx.dsptuneup_cloud.Tools;

import android.util.Log;

import com.orhanobut.hawk.Hawk;
import com.zx.dsptuneup_cloud.App;
import com.zx.dsptuneup_cloud.Util.Constants;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.List;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;


public class ProtocolServiceUtil {
    private static final String TAG = "TAGevent入参=";
    /**
     * @throws Exception
     * @deprecated: 获取心跳包
     */

    public static void selectHeartBeat()  {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol ="2E437669FFFF0001"+group_number+"0064000100020000656E642E";

        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                    Log.d(TAG, "Write auth error");
                }
            }
        });
    }
    //音频处理器回复一键查询各个设备所属编组命令
    public static void selectNum()  {
        // 2E437669 4810 FFFF 0001  0064  0002  0013  656E642E
        String protocol ="2E4376694810FFFF0000006477060010656E642E";
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                    Log.d(TAG, "Write auth error");
                }
            }
        });
    }
    /**
     * @throws Exception
     * @deprecated: 查询音频处理器14通道数据包
     */

    public static void selectData14Channel()  {

        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_14channl_request+Constants.udp_constans1+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                    Log.d(TAG, "Write auth error");
                }
            }
        });

    }
    /**
     * @throws Exception
     * @deprecated: 所属编组内查询音频处理器8路输出通道数据
     */
    public static void selectData8Channel() {

        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }

        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_8channl_request+Constants.udp_constans1+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //查询本地远程
    public static void selectDataRemot(){
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order__remote_request+Constants.udp_constans1+Constants.udp_end;

        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });


    }
//查询矩阵
    public static void selectDataMatrix(){
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_matrix_request+Constants.udp_constans1+Constants.udp_end;

        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });


    }
    //查询编组
    public static void selectEquipmentNumbe(){

        String protocol ="2E437669FFFF000100000064770500020000656E642E";
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });


    }
    //回复出厂设置
    public static void factoryReset(){
        //指令0003   长度0006  写死的值
   String macAdress="";
   if (Hawk.contains("macAdress")){
    macAdress=Hawk.get("macAdress");
   }
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol ="2E437669FFFF0001"+group_number+"006400030006"+ macAdress +"656E642E";

        Log.d("dataString=查询",protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });


    }
//输入Eq设置

    public static void setInputEqParameterData(int channel_inde, String event, int segment_index ,String type,int frequent,double  q,double gain) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+TenValueToHexUtils.TenToHexAndAppendZeroTo2(segment_index)+type+TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequent)
                +NumberBaseConversionUtil.tenDecimalToSixTeen(q)+NumberBaseConversionUtil.tenDecimalToSixTeen(gain);
     //   Log.d(TAG,parame.length()+" parame.length()="+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()));
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_iuput_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;
        Log.d(TAG,protocol+"通道="+ByteToString.strTo10(protocol.substring(28,30))+" 事件="+protocol.substring(30,32)+
                " 几段="+ByteToString.strTo10(protocol.substring(32,34))+" type="+protocol.substring(34,36)+"  频率="+ByteToString.strTo10(protocol.substring(36,40))+" q值="+NumberBaseConversionUtil.SixToDecimalTen(protocol.substring(40,44))+"  增益="+NumberBaseConversionUtil.SixToDecimalTen(protocol.substring(44,48)));
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //输入静音设置
    public static void setInputMuteParameterData(int channel_inde,String event,boolean cmute_tatus ) {
        String cmute="";//静音状态

        if (cmute_tatus){

            cmute=Constants.inputAndOutput_event_typeEnum.OPEN_MUTE;
        }else {

            cmute=Constants.inputAndOutput_event_typeEnum.CANLE_MUTE;

        }
        Log.d(TAG+"cmute","  cmute="+cmute+"   cmute_tatus="+cmute_tatus);
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+cmute;
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_iuput_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;
        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //输入音量设置
    public static void setInputVolumeParameterData(int channel_inde,String event,double volume) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+NumberBaseConversionUtil.tenDecimalToSixTeen(volume);
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_iuput_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;

        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //输入高切设置
    public static void setInputHighParameterData( int channel_inde,String event,String flag,int frequent) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+flag+TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequent);
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_iuput_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;
        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //输入低切设置
    public static void setInputBaseParameterData( int channel_inde,String event,String flag,int frequent) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+flag+TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequent);
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_iuput_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;
        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //设置远程本地
    public static void setRemote(String stutas){
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_seting_remote_request+Constants.udp_constans2+stutas+Constants.udp_end;
        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //输出Eq设置
    public static void setOutputEqParameterData(int channel_inde, String event, int segment_index ,String type,int frequent,double  q,double gain) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+TenValueToHexUtils.TenToHexAndAppendZeroTo2(segment_index)+type+TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequent)
                +NumberBaseConversionUtil.tenDecimalToSixTeen(q)+NumberBaseConversionUtil.tenDecimalToSixTeen(gain);
       // TenValueToHexUtils.tenToHexAndAppendZeroTo4Sign(gain);
        Log.d(TAG,parame.length()+" parame.length()="+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()));
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_output_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;
        Log.d(TAG,protocol+"通道="+ByteToString.strTo10(protocol.substring(28,30))+" 事件="+protocol.substring(30,32)+
                " 几段="+ByteToString.strTo10(protocol.substring(32,34))+" type="+protocol.substring(34,36)+"  频率="+ByteToString.strTo10(protocol.substring(36,40))+" q值="+NumberBaseConversionUtil.SixToDecimalTen(protocol.substring(40,44))+"  增益="+NumberBaseConversionUtil.SixToDecimalTen(protocol.substring(44,48)));
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }
    //输出静音设置
    public static void setOutputMuteParameterData(int channel_inde,String event,boolean cmute_tatus ) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }

        String cmute="";//静音状态
        if (cmute_tatus){

            cmute=Constants.inputAndOutput_event_typeEnum.OPEN_MUTE;
        }else {

            cmute=Constants.inputAndOutput_event_typeEnum.CANLE_MUTE;

        }

        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+cmute;
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_output_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;
        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });


    }
    //输出音量设置
    public static void setOutputVolumeParameterData(int channel_inde,String event,double volume) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+NumberBaseConversionUtil.tenDecimalToSixTeen(volume);
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_output_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2)+parame+Constants.udp_end;
        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });
    }

  /*  *//**
     * @throws Exception
     * @deprecated: 设置指定编组音频矩阵新版
     */
    public static void setupDeviceAudioMatrixByGroupNew( Integer input, Integer output,  Integer type, Integer gain)  {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(input)
                +TenValueToHexUtils.TenToHexAndAppendZeroTo2(output)+TenValueToHexUtils.TenToHexAndAppendZeroTo2(type)+TenValueToHexUtils.tenToHexAndAppendZeroTo4Sign(gain);
        Log.d("DeviceAudioMatrixByGroupNew入参11：","指令="+Constants.order_seting_matrix_request+"输入="+input+"  输出"+output+"  type="+type+"  gain="+gain+"   长度16进制"+  TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2));
       // String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(input) + TenValueToHexUtils.TenToHexAndAppendZeroTo2(output) + TenValueToHexUtils.TenToHexAndAppendZeroTo2(type) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(gainI);
        Log.d("DeviceAudioMatrixByGroupNew入参22：","指令="+Constants.order_seting_matrix_request+"输入="+TenValueToHexUtils.TenToHexAndAppendZeroTo2(input)+"  输出"+TenValueToHexUtils.TenToHexAndAppendZeroTo2(output)+"  type="+TenValueToHexUtils.TenToHexAndAppendZeroTo2(type)+"  gain="+TenValueToHexUtils.tenToHexAndAppendZeroTo4Sign(gain)+"   长度16进制"+  TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length()/2));
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_seting_matrix_request+"0005"+parame+Constants.udp_end;
        Log.d(TAG,protocol);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });
    }

/*    //输出高切频设置
    public static void setOutputHighParameterData(  int channel_inde,String event,String flag,int frequent) {
        String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                event+flag+TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequent);
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+Constants.group_number
                +Constants.priority_evel+Constants.order_output_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length())+parame+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });}
    //输出低切频设置
    public static void setOutputBassParameterData( int channel_inde,String event,String flag,int frequent) {
            String parame=TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel_inde)+
                    event+flag+TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequent);
            String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+Constants.group_number
                    +Constants.priority_evel+Constants.order_output_paramter_request+TenValueToHexUtils.TenToHexAndAppendZeroTo4(parame.length())+parame+Constants.udp_end;
            App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture channelFuture) throws Exception {
                    if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                    } else {
                    }
                }
            });
    }*/
    /**
     * 恢复出厂设置
     * operation        0x0A
     * element_type     0x01
     * */
  /*  public static void setReboot(){


        String protocol =  getProtocol(frameId,operation,element_type,"");
        Log.d(TAG,"protocol=="+protocol);

        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, "Write auth successful");
                } else {
                    Log.d(TAG, "Write auth error");
                }
            }
        });
    }*/
    //高低音参数设置
    public static void setLowHighParameterData( int index,int h_freq_bass,int  h_gain,int freq_bass,int l_gain) {

    }

    /**
     * @throws Exception
     * @deprecated: 所属编组内查询音频处理器音频矩阵数据
     */
    public void selectOrderMatrix( ) {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_matrix_request+Constants.udp_constans1+Constants.udp_end;
        Log.d(TAG,protocol);
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });
    }

    /**
     * @throws Exception
     * @deprecated: 所属编组内查询音频处理器高低音数据
     */
    public void setOrderHighBass( )  {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_high_bass_request+Constants.udp_constans1+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }

//	--------------------------------------------------------------------------------------------------------------------

    /**
     * @throws Exception
     * @deprecated: 所属编组内设置音频处理器输入参数
     */
    public void selectOrderIuputParamter()  {
        String group_number="";//当前设备编组
        if (Hawk.contains("group_number")){
            group_number=Hawk.get("group_number");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+group_number
                +Constants.priority_evel+Constants.order_iuput_paramter_request+Constants.udp_constans1+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }

    /**
     * @throws Exception
     * @deprecated: 所属编组内设置音频处理器输出参数
     */
    public void selectOrderOutputParamter()  {
        String groupHex=null;
        if(Hawk.contains("groupHex")){
            groupHex=Hawk.get("groupHex");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+Constants.group_number
                +Constants.priority_evel+Constants.order_output_paramter_request+Constants.udp_constans1+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });
    }

    /**
     * @throws Exception
     * @deprecated: 所属编组内设置音频处理器矩阵
     */
    public void selectOrderSetingMatrix( ) {
        String groupHex=null;
        if(Hawk.contains("groupHex")){
            groupHex=Hawk.get("groupHex");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+Constants.group_number
                +Constants.priority_evel+Constants.order_seting_matrix_request+Constants.udp_constans1+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });

    }

    /**
     * @throws Exception
     * @deprecated: 所属编组内设置音频处理器高低音数据
     */
    public void selectOrderSetingHighBass( ) {
        String groupHex=null;
        if(Hawk.contains("groupHex")){
            groupHex=Hawk.get("groupHex");
        }
        String protocol = Constants.udp_head+Constants.source_device+Constants.source_destination+Constants.group_number
                +Constants.priority_evel+Constants.order_seting_high_bass_request+Constants.udp_constans1+Constants.udp_end;
        App.getContext().getNettyClient().sendMsgToServer(protocol, new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {                //4
//                    Log.d(TAG, queryProtocol + "Write auth successful");
                } else {
                }
            }
        });
    }

    /**
     * @throws Exception
     * @deprecated: 所属编组内设置音频处理器高低音数据
     */
    public void selectDeviceRemoteByGroup(Integer group, Integer level, String ip, int port) throws Exception {
        //String protocol = get4810Protocol(group, level, "4108", "0000");
        String protocol =  Constants.order_seting_high_bass_request+Constants.order_seting_remote_request;

        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("所属编组内设置音频处理器高低音数据-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);

    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输入EQ
     */
    public void setupDeviceInputEQByGroup(Integer group, Integer channel, Integer index, Integer frequency, Float gain, Float q, Integer level, String ip, int port) throws Exception {
        int gainI = (int) Math.floor(gain * 100);
        int qI = (int) Math.floor(q * 100);
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + "01" + TenValueToHexUtils.TenToHexAndAppendZeroTo2(index) + "00" + TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequency) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(qI) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(gainI);
        String protocol = get4810Protocol(group, level, "410A", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输入EQ-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);

    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输入Mute(静音)
     */
    public static boolean setupDeviceInputMuteByGroup(Integer group, Integer channel, Integer mute, Integer level, String ip, int port) throws Exception {
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + "02" + TenValueToHexUtils.TenToHexAndAppendZeroTo2(mute);
        String protocol = get4810Protocol(group, level, "410A", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输入Mute-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输入Volume(音量)
     */
    public static boolean setupDeviceInputVolumeByGroup(Integer group, Integer channel, Float volume, Integer level, String ip, int port) throws Exception {
        int volumeI = (int) Math.floor(volume * 100);
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + "03" + TenValueToHexUtils.TenToHexAndAppendZeroTo4(volumeI);
        String protocol = get4810Protocol(group, level, "410A", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输入Volume-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输入高低切
     */
    public static boolean setupDeviceInputHigh_low_cutByGroup(Integer group, Integer channel, Integer operation, Integer frequency, Integer level, String ip, int port) throws Exception {
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + "04" + TenValueToHexUtils.TenToHexAndAppendZeroTo2(operation) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequency);
        String protocol = get4810Protocol(group, level, "410A", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输入高低切-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输出参数
     */
    public static boolean setupDeviceOutputByGroup(Integer group, Integer channel, Integer index, Integer frequency, Float gain, Float q, Integer level, String ip, int port) throws Exception {
        gain = gain * 100;
        int gainI = (int) Math.floor(gain);
        q = q * 100;
        int qI = (int) Math.floor(q);
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + TenValueToHexUtils.TenToHexAndAppendZeroTo2(index) + "00" + TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequency) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(qI) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(gainI);
        String protocol = get4810Protocol(group, level, "410C", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输出参数-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输出EQ
     */
    public static boolean setupDeviceOutputEQByGroup(Integer group, Integer channel, Integer index, Integer frequency, Float gain, Float q, Integer level, String ip, int port) throws Exception {
        int gainI = (int) Math.floor(gain * 100);
        int qI = (int) Math.floor(q * 100);
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + "01" + TenValueToHexUtils.TenToHexAndAppendZeroTo2(index) + "00" + TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequency) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(qI) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(gainI);
        String protocol = get4810Protocol(group, level, "410C", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输出EQ-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输出Mute(静音)
     */
    public static boolean setupDeviceOutputMuteByGroup(Integer group, Integer channel, Integer mute, Integer level, String ip, int port) throws Exception {
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + "02" + TenValueToHexUtils.TenToHexAndAppendZeroTo2(mute);
        String protocol = get4810Protocol(group, level, "410C", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输出Mute-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组输出Volume(音量)
     */
    public static boolean setupDeviceOutputVolumeByGroup(Integer group, Integer channel, Float volume, Integer level, String ip, int port) throws Exception {
        int volumeI = (int) Math.floor(volume * 100);
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + "03" + TenValueToHexUtils.TenToHexAndAppendZeroTo4(volumeI);
        String protocol = get4810Protocol(group, level, "410C", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组输出Volume-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组音频矩阵
     */
    public static boolean setupDeviceAudioMatrixByGroup(Integer group, Integer channel, Integer index, Integer frequency, Float gain, Float q, Integer level, String ip, int port) throws Exception {
        gain = gain * 100;
        int gainI = (int) Math.floor(gain);
        q = q * 100;
        int qI = (int) Math.floor(q);
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + TenValueToHexUtils.TenToHexAndAppendZeroTo2(index) + "00" + TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequency) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(qI) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(gainI);
        String protocol = get4810Protocol(group, level, "410E", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("查询指定编组高低音数据-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组高低音
     */
    public static boolean setupDeviceHigh_low_volumeByGroup(Integer group, Integer channel, Integer index, Integer frequency, Float gain, Float q, Integer level, String ip, int port) throws Exception {
        gain = gain * 100;
        int gainI = (int) Math.floor(gain);
        q = q * 100;
        int qI = (int) Math.floor(q);
        String data = TenValueToHexUtils.TenToHexAndAppendZeroTo2(channel) + TenValueToHexUtils.TenToHexAndAppendZeroTo2(index) + "00" + TenValueToHexUtils.TenToHexAndAppendZeroTo4(frequency) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(qI) + TenValueToHexUtils.TenToHexAndAppendZeroTo4(gainI);
        String protocol = get4810Protocol(group, level, "4110", data);
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组高低音-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组Remote 00本地，01远程
     */
    public static boolean setupDeviceRemoteByGroup(Integer group, Integer mode, Integer level, String ip, int port) throws Exception {
        String protocol = get4810Protocol(group, level, "4112", TenValueToHexUtils.TenToHexAndAppendZeroTo4(mode));
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组Remote-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

    /**
     * @throws Exception
     * @deprecated: 设置指定编组基音频端口号
     */
    public static boolean setupDeviceBasePortByGroup(Integer group, Integer basePort, Integer level, String ip, int port) throws Exception {
        String protocol = get4810Protocol(group, level, "4114", TenValueToHexUtils.TenToHexAndAppendZeroTo4(basePort));
        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
        System.out.println("设置指定编组基音频端口号-" + protocol);
        UDPClient.send(bytes, InetAddress.getByName(ip), port);
        return true;
    }

//    /**
//     * @throws Exception
//     * @deprecated: 设置指定编组MUTE(静音)
//     */
//    public static boolean setupDeviceMuteByGroup(Integer group, Integer mute, Integer level, String ip, int port) throws Exception {
//        String data = "00" + TenValueToHexUtils.TenToHexAndAppendZeroTo2(mute);
//        String protocol = get4810Protocol(group, level, "410A", data);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        System.out.println("查询指定编组高低音数据-" + protocol);
//        UDPClient.send(bytes, InetAddress.getByName(ip), port);
//        return true;
//    }

//    /**
//     * @throws Exception
//     * @deprecated: 设置指定编组Volume(音量)
//     */
//    public static boolean setupDeviceVolumeByGroup(Integer group, Integer mute, Integer level, String ip, int port) throws Exception {
//        String data = "00" + TenValueToHexUtils.TenToHexAndAppendZeroTo2(mute);
//        String protocol = get4810Protocol(group, level, "410C", data);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        System.out.println("查询指定编组高低音数据-" + protocol);
//        UDPClient.send(bytes, InetAddress.getByName(ip), port);
//        return true;
//    }

    private static String get4810Protocol(Integer group, Integer level, String order, String data) {
        StringBuffer sb = new StringBuffer();
        sb.append("2E43766948100001").append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(group)).append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(level)).append(order).append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(data.length() / 2)).append(data).append("656E642E");
        return sb.toString();
    }
//	/**
//	 * @throws Exception
//	 * @deprecated: 播放本地音频
//	 */
//	public static boolean play(String id, String frameId, Integer model, List<Integer> sorts) throws Exception{
//		SocketVo v = getSocket(id);
//		DatagramSocket socket = v.getSocket();
//		if (socket == null){
//			return false;
//		}
//		String hexmodel = TenValueToHexUtils.TenToHexAndAppendZeroTo2(model);
////		String protocol = getProtocol(frameId, "0004", "0704"+hexNo);
//		StringBuffer stringBuffer=new StringBuffer();
//		stringBuffer.append("2E437669");
//		stringBuffer.append(frameId);
//		stringBuffer.append("0004");
//		StringBuffer sb = new StringBuffer();
//		for (Integer sort : sorts) {
//			sb.append(TenValueToHexUtils.TenToHexAndAppendZeroTo2(sort));
//		}
//		String s1 = hexmodel + sb.toString();
//		String s = new StringBuffer().append("11").append(TenValueToHexUtils.TenToHexAndAppendZeroTo2(s1.length()/2)).append(s1).toString();
//		int len = s.length() / 2;
//		String protocol = stringBuffer.append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(len)).append(s).append("656E642E").toString();
//		byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//		System.out.println("播放协议-"+protocol);
//		DatagramPacket p = new DatagramPacket(bytes,bytes.length,v.getAddress(),v.getPort());
//		socket.send(p);
//		return true;
//	}

    //    private static SocketVo getSocket(String id) {
//        SocketVo v = (SocketVo) ConcurrentHashMapUtil.get("socket_" + id);
//        if (v != null) {
//            return v;
//        } else {
//            int count = 0;
//            while (count > 10) {
//                v = (SocketVo) ConcurrentHashMapUtil.get("socket_" + id);
//                if (v == null) {
//                    count++;
//                } else {
//                    break;
//                }
//            }
//        }
//        return v;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 停止播放
//     */
//    public static boolean stop(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        if (v == null) {
//            return false;
//        }
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        StringBuffer stringBuffer = new StringBuffer();
//        stringBuffer.append("2E437669");
//        stringBuffer.append(frameId);
//        stringBuffer.append("0004");
//        String s = "1000";
//        int len = s.length() / 2;
//        String protocol = stringBuffer.append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(len)).append(s).append("656E642E").toString();
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        System.out.println("停止播放-" + protocol);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 下发文件命令
//     */
//    public static boolean upload(String id, String frameId, Integer size, Integer sort) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String hexNo = TenValueToHexUtils.TenToHexAndAppendZeroTo8(size);
//        String hexSort = TenValueToHexUtils.TenToHexAndAppendZeroTo2(sort);
////		String protocol = getProtocol(frameId, "0004", "0704"+hexNo);
//        StringBuffer stringBuffer = new StringBuffer();
//        stringBuffer.append("2E437669");
//        stringBuffer.append(frameId);
//        stringBuffer.append("0004");
//        String s = "0704" + hexNo + "0b01" + hexSort;
//        int len = s.length() / 2;
//        String protocol = stringBuffer.append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(len)).append(s).append("656E642E").toString();
////		System.out.println(protocol);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 设置机号
//     */
//    public static boolean deviceNo(String id, Integer deviceNo, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String hexNo = TenValueToHexUtils.TenToHexAndAppendZeroTo4(deviceNo);
//        String protocol = getProtocol(frameId, "0004", "0102" + hexNo);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 删除音乐
//     */
//    public static boolean delMusic(String id, Integer sort, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String hexNo = TenValueToHexUtils.TenToHexAndAppendZeroTo2(sort);
//        String protocol = getProtocol(frameId, "0004", "0c01" + hexNo);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 根据机号关闭设备
//     */
//    public static boolean close(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "0004", "020100");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 根据机号重启设备
//     */
//    public static boolean restart(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "0004", "14");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    private static String getProtocol(String frameId, String operation, String data) {
//        StringBuffer stringBuffer = new StringBuffer();
//        stringBuffer.append("2E437669");
//        stringBuffer.append(frameId);
//        stringBuffer.append(operation);
//        int len = data.length() / 2;
//        stringBuffer.append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(len)).append(data).append("656E642E");
//        return stringBuffer.toString();
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 根据机号开启设备
//     */
//    public static boolean open(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "0004", "020101");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 在线升级
//     */
//    public static boolean onlineUpgrade(String id, String frameId, String filePath) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        StringBuffer stringBuffer = new StringBuffer();
//        StringBuffer stringBuffer2 = new StringBuffer();
//        stringBuffer.append("2E437669");
//        stringBuffer.append(frameId);
//        stringBuffer.append("0004");
//        int len = filePath.length();
//        String hexlen = TenValueToHexUtils.TenToHexAndAppendZeroTo2(len);
//        len += 2;
//        String hexlen1 = TenValueToHexUtils.TenToHexAndAppendZeroTo4(len);
//        stringBuffer.append(hexlen1).append("09").append(hexlen);
//        stringBuffer2.append(filePath.getBytes()).append("656E642E");
//        byte[] bytes = ByteToString.hexStringToByteArray(stringBuffer.toString());
//        byte[] bytes2 = ByteToString.hexStringToByteArray(stringBuffer2.toString());
//        byte[] bytes1 = ArrayUtils.addAll(bytes, filePath.getBytes());
//        byte[] bytes3 = ArrayUtils.addAll(bytes1, bytes2);
//        DatagramPacket p = new DatagramPacket(bytes3, bytes3.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 下发文件
//     */
//    public static boolean uploadFile(String id, String frameId, String hexIndex, byte[] bytes) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        StringBuffer stringBuffer = new StringBuffer();
//        StringBuffer stringBuffer2 = new StringBuffer();
//        stringBuffer.append("2E437669");
//        stringBuffer.append(frameId);
//        stringBuffer.append("0008");
//        int datalen = bytes.length + 7;
//        String hexlen = TenValueToHexUtils.TenToHexAndAppendZeroTo4(bytes.length);
//        String hexlen1 = TenValueToHexUtils.TenToHexAndAppendZeroTo4(datalen);
//        stringBuffer.append(hexlen1).append("02").append(hexIndex).append(hexlen);
//        stringBuffer2.append("656E642E");
//        byte[] bytes1 = ByteToString.hexStringToByteArray(stringBuffer.toString());
//        byte[] bytes2 = ByteToString.hexStringToByteArray(stringBuffer2.toString());
//        byte[] bytes3 = ArrayUtils.addAll(bytes1, bytes);
//        byte[] bytes4 = ArrayUtils.addAll(bytes3, bytes2);
//        DatagramPacket p = new DatagramPacket(bytes4, bytes4.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//
//    /**
//     * @throws Exception
//     * @deprecated: 设置音量
//     */
//    public static boolean volume(String id, Integer volume, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String vokumeHex = TenValueToHexUtils.TenToHexAndAppendZeroTo2(volume);
//        String protocol = getProtocol(frameId, "0004", "0301" + vokumeHex);
//        System.out.println("设置音量：" + protocol);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 设置采样率
//     */
//    public static boolean sampleRate(String id, Integer sampleRate) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String vokumeHex = TenValueToHexUtils.TenToHexAndAppendZeroTo4(sampleRate);
//        String frameId = UUIDUtil.get4UUID().toUpperCase();
//        String protocol = getProtocol(frameId, "0004", "0402" + vokumeHex);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取剩余空间
//     */
//    public static boolean getDeviceSize(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "0d");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取MAC
//     */
//    public static boolean getMac(SocketVo v, String frameId) throws Exception {
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "0E");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
////		System.out.println("mac协议-"+protocol);
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取MAC
//     */
//    public static boolean getMac(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "0E");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        System.out.println("mac协议-" + protocol);
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取IMEI
//     */
//    public static boolean getIMEI(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "0F");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        System.out.println("imei协议-" + protocol);
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取采样率
//     */
//    public static boolean getSampleRate(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "04");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取序列号
//     */
//    public static boolean serialNo(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "06");
//        System.out.println("获取序列号-" + protocol);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取网卡号
//     */
//    public static boolean networkCardNo(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "05");
//        System.out.println("获取网卡号-" + protocol);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取版本号
//     */
//    public static boolean version(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "0A");
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    /**
//     * @throws Exception
//     * @deprecated: 获取音量
//     */
//    public static boolean getVolume(String id, String frameId) throws Exception {
//        SocketVo v = getSocket(id);
//        DatagramSocket socket = v.getSocket();
//        if (socket == null) {
//            return false;
//        }
//        String protocol = getProtocol(frameId, "000A", "13");
//        System.out.println("发送获取音量协议-" + protocol);
//        byte[] bytes = ByteToString.hexStringToByteArray(protocol);
//        DatagramPacket p = new DatagramPacket(bytes, bytes.length, v.getAddress(), v.getPort());
//        socket.send(p);
//        return true;
//    }
//
//    public static byte[] speakData(byte[] b) {
//        StringBuffer stringBuffer = new StringBuffer();
//        StringBuffer stringBuffer2 = new StringBuffer();
//        stringBuffer.append("2E437669");
//        stringBuffer.append(UUIDUtil.get4UUID().toUpperCase());
//        stringBuffer.append("0006");
//        stringBuffer.append(TenValueToHexUtils.TenToHexAndAppendZeroTo4(b.length));
//        stringBuffer2.append("656E642E");
//        byte[] bytes = ByteToString.hexStringToByteArray(stringBuffer.toString());
//        byte[] bytes2 = ByteToString.hexStringToByteArray(stringBuffer2.toString());
//        byte[] bytes1 = ArrayUtils.addAll(bytes, b);
//        return ArrayUtils.addAll(bytes1, bytes2);
//    }
  /*  public static void main(String[] args) throws Exception {
        selectDeviceInfoByGroup(2, "255.255.255.255", 6003);
    }*/
}
